package cn.anc.aonicardv.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.viewpager.widget.ViewPager;

/**
 * Created by yangdai on 2018/4/23.
 */

public class ControlSlideViewPager extends ViewPager {

    public ControlSlideViewPager(Context context) {
        super(context);
    }

    public ControlSlideViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    private Boolean isScroll = true;

    public void setScroll(boolean scroll) {
        synchronized (isScroll) {
            isScroll = scroll;
        }
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (isScroll)
            return super.onInterceptTouchEvent(ev);
        else return false;
    }
}
